<?php
defined('_JEXEC') or die('Restricted access'); 
jimport('joomla.application.component.view');
class AppViewApp extends JView{
	//Override phuong thuc display cuar jview
	function display(){
		
		//echo '<h1>Danh sách app</h1>';
		//Kiem tra su kien bam nut new
		$task = JRequest::getVar("task");
		switch($task){
			case 'add': //Nhan New
				$this->editView();
				$this->editToolbar();
				
				break;
			default: //Cac truong hop con lai
				$this->defaultView();
				$this->defaultToolbar();
		}
		
		//$this->display();
	}	
	
	//Ham hien thi toolbar
	private function defaultToolbar(){
		JToolBarHelper::title("Danh sách app");
		JToolBarHelper::addNew();
		JToolBarHelper::editList();
		JToolBarHelper::publishList();
		JToolBarHelper::unpublishList();
	}
	
	//Hien thi form nhap gia tri
	private function defaultView(){
		?>
			<form name="adminForm" method="post" 
			action="?option=com_app">
			<input type="hidden" name="task" />
			
			<h1>Xin chao! Day la form nhap app</h1>
			<?php 
			//lay noi dung da nhap
			echo 'Ban da nhap: '.JRequest::getVar("title");
			
			?>
			</form>
		<?php 
	}
	
	//Man hinh sua app
	public function editToolbar(){
		JToolBarHelper::title("Cập nhật thông tin app");
		JToolBarHelper::save();
		JToolBarHelper::cancel();
	}
	
	//Ham hien thi lại sau khi sua
	function editView(){
		$this->assignRef("form", $this->get('Form'));
		$this->setLayout('edit');
		parent::display();
	?>
		 <!--  <form name="adminForm" method="post"
				action="?option=com_app">
			<input type="hidden" name="task" />
			
			<label for="title">Nhập nội dung</label>
			<input type="text" id="title" name="title" />
		</form>
		 -->
		 
	<?php 
	}

}

//KHong dong the php